package com.msb.mall.product.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/**
 * @Auther: xixifeng
 * @Date: 2022/11/9 - 11 - 09 - 20:39
 * @Description: com.example.mallauthserver.config
 * @version: 1.0
 */
@Configuration
public class MySessionConfig {


    /**
     * 自定义Cookie的配置
     * @return
     */
    @Bean
    public CookieSerializer cookieSerializer(){

         DefaultCookieSerializer defaultCookieSerializer = new DefaultCookieSerializer();

         defaultCookieSerializer.setDomainName("msb.com");
         defaultCookieSerializer.setCookieName("xxfSession");
         return defaultCookieSerializer;
    }


    /**
     * 对存储在Redis中的数据指定序列化的方式
     * @return
     */
    @Bean
    public RedisSerializer<Object> redisSerializer(){

        return new GenericJackson2JsonRedisSerializer();
    }

}
